package com.Jano.mapper;

import com.Jano.model.UserModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * description: AdminUserMapper <br>
 * date: 2022/7/10 8:24 PM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */

@Mapper
public interface UserMapper {
    /**
     * 根据用户id查询用户信息
     * @param id
     * @return
     * @throws Exception
     */
    @Select("select * from au_user where id = #{id}")
    UserModel selectById(int id);

    /**
     * 用户登录
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    @Select("SELECT u.id,u.username,u.`password`,r.`roleCode`\n" +
            "FROM au_user u LEFT JOIN au_role r\n" +
            "ON u.`roleId`=r.`id`\n" +
            "WHERE u.username=#{username} AND u.password=#{password}")
    UserModel selectByLogin(@Param("username") String username, @Param("password") String password);
}
